<?php

namespace App\Providers;

use App\Url;
use Illuminate\Support\ServiceProvider;
use Illuminate\Http\Request;
use App\Rule;
class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot( Request $request)
    {
        \Carbon\Carbon::setLocale('zh');

        $rules = Rule::all();

        $uri = $request->path();
        $ll=Url::where('url',$uri)->first();
        $title=$ll['name'];
        Url::where('id',$ll['pid'])->update(['state'=>1]);
        Url::where('id','!=',$ll['pid'])->update(['state'=>0]);
        $urls=Url::orderBy('listRank','asc')->get();
        $aliOssUrl='http://link51888.oss-eu-central-1.aliyuncs.com';
        view()->share(['rules'=>$rules,'urls'=>$urls ,'title'=>$title,'aliOssUrl'=>$aliOssUrl,'actice'=>$uri]);
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
